package com.jy.datapipeline.common.util;

import com.jy.datapipeline.export.entity.DataStoreInfoModel;
import io.minio.MinioClient;
import lombok.SneakyThrows;

public class minioUtils {
    private MinioClient client;
    @SneakyThrows
    public void init(DataStoreInfoModel dsim){
        if(dsim.getStoreType().equals("minio")) {

            MinioClient minioClient = new MinioClient(dsim.getHost(), dsim.getUserName(),
                dsim.getPassword());
            this.client=minioClient;
        }
    }
    @SneakyThrows
    public boolean bucketExists(String bucketName) {
       return this.client.bucketExists(bucketName);
    }
    @SneakyThrows
    public void makeBucketIfNotExist(String bucketName) {
            if (!this.bucketExists(bucketName)) {
                this.client.makeBucket(bucketName);
            }
    }

}
